package com.lifp.controller;

import com.lifp.service.IotMqttGateway;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lifp
 * @date 2023/10/20
 */
@RestController
@RequestMapping("test")
public class TestController {
    @Autowired
    private IotMqttGateway mqttGateway;

    @GetMapping("send/{topic}/{payload}")
    public String sendMessage2Mqtt(@PathVariable String topic,@PathVariable String payload){
        mqttGateway.sendMessage2Mqtt(topic,payload);

        return "success";
    }

    @GetMapping("send/{topic}/{qos}/{payload}")
    public String sendMessage2DefaultTopic(@PathVariable String topic,@PathVariable Integer qos,@PathVariable String payload){
        mqttGateway.sendMessage2Mqtt(topic,qos,payload);

        return "success";
    }
}
